package com.bwie.controller;

import com.bwie.pojo.User;
import com.bwie.service.UserService;
import com.bwie.utils.R;
import com.bwie.vo.LoginInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author GaoYiJie
 * @Description
 * @Create 2025/3/12 9:09
 * @Version 1.0
 */
@RestController
@RequestMapping("/user/user")
public class UserController {

    @Autowired
    UserService userService;

    /**
     * 注册
     * @param user
     * @return
     */
    @PostMapping("/register")
    public R register(@RequestBody User user){
        return userService.register(user);
    }

    /**
     * 发送验证码
     * @param phone
     * @return
     */
    @PostMapping("/sendPhoneCode/{phone}")
    public R sendPhoneCode(@PathVariable("phone") String phone){
        return userService.sendPhoneCode(phone);
    }

    /**
     * 登录
     * @param loginInfoVo
     * @return
     */
    @PostMapping("/login")
    public R login(@RequestBody LoginInfoVo loginInfoVo){
        return userService.login(loginInfoVo);
    }

    /**
     * 根据ID查询邀请人数
     * @param
     * @return
     */
    @PostMapping("/getCount")
    public R getCount(){
        return userService.getCount();
    }

    /**
     * 扣除费用
     * @param
     * @return
     */
    @PostMapping("/updateFee")
    public R updateFee(@RequestBody User user){
        return userService.updateFee(user);
    }
}
